package com.yanqu.road.server.manger.activity.guagifts.service;

import com.google.protobuf.InvalidProtocolBufferException;
import com.yanqu.road.pb.activity.GuaGiftsProto;
import com.yanqu.road.pb.activity.QixiProto;
import com.yanqu.road.pb.syncMessage.SyncMessage;
import com.yanqu.road.server.game.service.IGameServiceCommand;
import com.yanqu.road.server.manger.activity.guagifts.GuaGiftsMgr;
import com.yanqu.road.server.manger.activity.qixi.QixiMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.sync.message.SyncResponse;
import com.yanqu.road.utils.YanQuMessageUtils;

public class GuaNewBroadcastFromOtherServiceCmd implements IGameServiceCommand {
    @Override
    public SyncResponse execute(SyncMessage.Request request) throws InvalidProtocolBufferException {
        SyncResponse syncResponse = new SyncResponse();
        GuaGiftsProto.CrossGuaGiftsGiftBroadcastMsg resultMsg = GuaGiftsProto.CrossGuaGiftsGiftBroadcastMsg.parseFrom(request.getDataBytes());
        if (GuaGiftsMgr.getConfig() != null) {
            GuaGiftsProto.CrossGuaGiftsGiftBroadcastMsg.Builder builder = resultMsg.toBuilder().setActivityId(GuaGiftsMgr.getConfig().getActivityId());
            GamePlayerMgr.sendPacket(0, YanQuMessageUtils.buildMessage(CrossProtocol.C_GUAGIFTS_SEND_GIFT_BROADCAST, builder));
        }

        return syncResponse;
    }
}
